# This currently builds some sample user space programs

CFLAGS =	-I.. -Wall -g -ansi -pedantic
LDFLAGS = -L.. -lmsr

MSRDEMO=	msr
MSRDEMOSRCS=	msr.c
MSRDEMOOBJS=	$(MSRDEMOSRCS:.c=.o)

MSRQUICKERASER=		msr-quick-eraser
MSRQUICKERASEROBJS=	msr-quick-eraser.o

MSRQUICKISODUMPER=		msr-quick-iso-dumper
MSRQUICKISODUMPEROBJS=		msr-quick-iso-dumper.o

MSRQUICKRAWDUMPER=		msr-quick-raw-dumper
MSRQUICKRAWDUMPEROBJS=		msr-quick-raw-dumper.o

MAKSTRIPEQUICKCLONE=		makstripe-quick-clone
MAKSTRIPEQUICKCLONEOBJS=	makstripe-quick-clone.o

FILEBITREVERSER=		file-bit-reverser
FILEBITREVERSEROBJS=		file-bit-reverser.o

FILEBITSHIFTER=		file-bit-shifter
FILEBITSHIFTEROBJS=		file-bit-shifter.o

FILEFIELDVISUALIZER=		file-field-visualizer
FILEFIELDVISUALIZEROBJS=		file-field-visualizer.o

all:	$(MSRDEMO) $(MSRQUICKERASER) $(MSRQUICKISODUMPER) $(MSRQUICKRAWDUMPER) \
	$(MAKSTRIPEQUICKCLONE) \
	$(FILEBITREVERSER) $(FILEBITSHIFTER) $(FILEFIELDVISUALIZER)

$(MSRDEMO): $(MSRDEMOOBJS)
	$(CC) -o $(MSRDEMO) $(MSRDEMOOBJS) $(LDFLAGS)

$(MSRQUICKERASER): $(MSRQUICKERASEROBJS)
	$(CC) -o $(MSRQUICKERASER) $(MSRQUICKERASEROBJS) $(LDFLAGS)

$(MSRQUICKISODUMPER): $(MSRQUICKISODUMPEROBJS)
	$(CC) -o $(MSRQUICKISODUMPER) $(MSRQUICKISODUMPEROBJS) $(LDFLAGS)

$(MSRQUICKRAWDUMPER): $(MSRQUICKRAWDUMPEROBJS)
	$(CC) -o $(MSRQUICKRAWDUMPER) $(MSRQUICKRAWDUMPEROBJS) $(LDFLAGS)

$(MAKSTRIPEQUICKCLONE): $(MAKSTRIPEQUICKCLONEOBJS)
	$(CC) -o $(MAKSTRIPEQUICKCLONE) $(MAKSTRIPEQUICKCLONEOBJS) $(LDFLAGS)

$(FILEBITREVERSER): $(FILEBITREVERSEROBJS)
	$(CC) -o $(FILEBITREVERSER) $(FILEBITREVERSEROBJS) $(LDFLAGS)

$(FILEBITSHIFTER): $(FILEBITSHIFTEROBJS)
	$(CC) -o $(FILEBITSHIFTER) $(FILEBITSHIFTEROBJS) $(LDFLAGS)

$(FILEFIELDVISUALIZER): $(FILEFIELDVISUALIZEROBJS)
	$(CC) -o $(FILEFIELDVISUALIZER) $(FILEFIELDVISUALIZEROBJS) $(LDFLAGS) -lncurses

.c.o:
	$(CC) $(CFLAGS) -o $@ -c $<

install:
	install -m755 -D $(MSRDEMO) $(DESTDIR)/usr/bin/$(MSRDEMO)
	install -m755 -D $(MSRQUICKERASER) $(DESTDIR)/usr/bin/$(MSRQUICKERASER)
	install -m755 -D $(MSRQUICKISODUMPER) $(DESTDIR)/usr/bin/$(MSRQUICKISODUMPER)
	install -m755 -D $(MSRQUICKRAWDUMPER) $(DESTDIR)/usr/bin/$(MSRQUICKRAWDUMPER)
	install -m755 -D $(MAKSTRIPEQUICKCLONE) $(DESTDIR)/usr/bin/$(MAKSTRIPEQUICKCLONE)
	install -m755 -D $(FILEBITREVERSER) $(DESTDIR)/usr/bin/$(FILEBITREVERSER)
	install -m755 -D $(FILEBITSHIFTER) $(DESTDIR)/usr/bin/$(FILEBITSHIFTER)

clean:
	rm -rf *.o *~
	rm -rf $(MSRDEMO) $(MSRQUICKERASER) $(MSRQUICKISODUMPER) $(MSRQUICKRAWDUMPER)
	rm -rf $(MAKSTRIPEQUICKCLONE)
	rm -rf $(FILEBITREVERSER) $(FILEBITSHIFTER) $(FILEFIELDVISUALIZER)
